<?php
header("Content-Type:application;charset:utf-8");

if($_SERVER["REQUEST_METHOD"]=="GET"){
    $result=array("msg"=>"抱歉.暂不支持get请求","status"=>-1);
    print_r(json_encode($result));
    return;
}

if(!(isset($_POST["uphone2"])&&isset($_POST["upwd"]))){
    $result=array("msg"=>"手机号或密码不能为空","status"=>-2);
    print_r(json_encode($result));
    return;
}

$uname=$_POST["uphone2"];
$upwd=$_POST["upwd"];

include "DBhelper.php";

$sql="SELECT `id`,`uname`,`upwd`,`utelphone`,`uemail`,`urealname` FROM `usermessage` WHERE `utelphone`='".$uname."' AND `upwd`='".$upwd."'";

$resultData=sqlQuery($sql);

if($resultData->num_rows>=1){
    //如果登录,就把当前的登陆者信息保存到session 中
    session_start();
    $userData=$resultData->fetch_assoc();
    $_SESSION["usermessage"]=$userData;
    $result=array("msg"=>"登录成功","status"=>1,"data"=>$userData);
    print_r(json_encode($result));
}else{
    $result=array("msg"=>"登录失败","status"=>-3);
    print_r(json_encode($result));
}


